package com.diy.sigmund.diycommon.designpatterns.factorymethod.pizza2;

/**
 * @author ylm-sigmund
 * @since 2022/2/8 14:56
 */
public class CheesePizza extends Pizza {

    PizzaIngredientFactory pizzaIngredientFactory;

    /**
     * 要制作pizza，需要工厂提供原料
     */
    public CheesePizza(PizzaIngredientFactory pizzaIngredientFactory) {
        this.pizzaIngredientFactory = pizzaIngredientFactory;
    }

    /**
     * 原料全部来自工厂
     */
    @Override
    void prepare() {
        System.out.println("Prepareing" + name);
        dough = pizzaIngredientFactory.createDough();
        sauce = pizzaIngredientFactory.createSauce();
        cheese = pizzaIngredientFactory.createCheese();
    }
}
